#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
long long l,r,n,jg,ans;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	jg=r-l+1;
	if (jg>=n) ans=n-1;
	  else 
	  {
	  	l=l%n;r=r%n;
	  	if (r<l) ans=n-1;
	  	  else ans=r;
	  }
	cout<<ans;
	return 0;
}
